package dborm

import (
	"time"
)

//Manageserver struct
type Manageserver struct {
	UUID         string    `xorm:"not null pk TEXT 'UUID'"`
	HostIP       string    `xorm:"default \"0.0.0.0\" TEXT 'host_ip'"`
	HostPort     int       `xorm:"not null default 0 INTEGER"`
	Mode         int       `xorm:"not null default 0 INTEGER"`
	Protocol     int       `xorm:"not null index default 0 INTEGER"`
	MqttServerID int       `xorm:"index INTEGER 'mqtt_server_id'"`
	Param1       string    `xorm:"TEXT 'param1'"`
	Param2       string    `xorm:"TEXT 'param2'"`
	Param3       string    `xorm:"TEXT 'param3'"`
	Param4       string    `xorm:"TEXT 'param4'"`
	CreatedAt    time.Time `xorm:"created"`
	UpdatedAt    time.Time `xorm:"updated"`
	DeletedAt    time.Time `xorm:"deleted"`
	//string       `xorm:""`
	//Constraint   string `xorm:""fk_tcpConf_mqttServer_1""`
	//References   string `xorm:""mqttServer""`
	//Constraint   string `xorm:""fk_tcpConf_mqttServer_1""`
	//References   string `xorm:""mqttServer""`
	//Constraint   string `xorm:""fk_tcpConf_mqttServer_1""`
	//References   string `xorm:""mqttServer""`
	//string       `xorm:""`
}

/*SQLBack:
DROP INDEX "main"."IDX_tcpConf_mqtt_ip_port";

DROP INDEX "main"."IDX_tcpConf_mqtt_server_id";

ALTER TABLE "main"."tcpConf" RENAME TO "_tcpConf_old_20230913_1";

CREATE TABLE "main"."tcpConf" (
  "UUID" TEXT NOT NULL,
  "host_ip" TEXT DEFAULT "0.0.0.0",
  "host_port" INTEGER NOT NULL DEFAULT 0,
  "mode" INTEGER NOT NULL DEFAULT 0,
  "protocol" INTEGER NOT NULL DEFAULT 0,
  "mqtt_server_id" INTEGER,
  "param1" TEXT,
  "param2" TEXT,
  "param3" TEXT,
  "param4" TEXT,
  "created_at" DATETIME,
  "updated_at" DATETIME,
  "deleted_at" DATETIME,
  PRIMARY KEY ("UUID")
);

INSERT INTO "main"."tcpConf" ("UUID", "host_ip", "host_port", "mode", "protocol", "mqtt_server_id", "param1", "param2", "param3", "param4", "created_at", "updated_at", "deleted_at") SELECT "UUID", "host_ip", "host_port", "mode", "protocol", "mqtt_server_id", "param1", "param2", "param3", "param4", "created_at", "updated_at", "deleted_at" FROM "main"."_tcpConf_old_20230913_1";

CREATE INDEX "main"."IDX_tcpConf_mqtt_ip_port"
ON "tcpConf" (
  "host_ip" ASC,
  "host_port" ASC
);

CREATE INDEX "main"."IDX_tcpConf_mqtt_server_id"
ON "tcpConf" (
  "mqtt_server_id" ASC
);
*/
